<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>判断是否成年</title>
</head>
<body>
<input type="text" id="age" />
<p id="result"></p>
<button onclick="myFunction()">判断是否成年</button>
<script>

	function myFunction()
	{
		var result = document.getElementById("age").value;
		if (result > 18) {
			document.getElementById("result").innerHTML = "你已经成年了";
			document.getElementById("result").style.color = "black";
		}
		else {
			document.getElementById("result").innerHTML = "你还未成年";
			document.getElementById("result").style.color = "red";
		}

	}

</script>




</body>
</html>